package dataContracts;

public class CommandParser {
	public static CommandType getCommandType(String cmd) {
		try {
			return CommandType.valueOf(cmd.split(":")[0]);
		} catch (IllegalArgumentException ex) {
			return CommandType.Invalid;
		}
	}
	
	public static String buildCommand(CommandType cmd, String cmdText) {
		return cmd.toString() + ":" + cmdText;
	}
	
	public static String getCommandText(CommandType cmd, String cmdText) {
		int len = cmd.toString().length() + 1; // +1 for the colon separator
		
		return cmdText.substring(len);
	}
}
